package com.hmall.search.controller;


import com.hmall.common.domain.PageDTO;
import com.hmall.search.domain.dto.ItemDTO;
import com.hmall.search.domain.query.ItemPageQuery;
import com.hmall.search.domain.vo.ItemAggVO;
import com.hmall.search.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "搜索相关接口")
@RestController
@RequestMapping("/search")
@RequiredArgsConstructor
public class SearchController {

    private final SearchService searchService;

    /**
     * 搜索商品
     *
     * @param
     * @return
     */
    @ApiOperation("搜索商品")
    @GetMapping("/list")
    public PageDTO<ItemDTO> search(ItemPageQuery query) {
        return searchService.search(query);
    }


    /**
     *  过滤条件聚合
     */
    @ApiOperation("过滤条件聚合")
    @PostMapping("/filters")
    public ItemAggVO filterItem(@RequestBody ItemPageQuery query) {
        return searchService.filterItem(query);
    }

}
